package com.solidumgame.ninja.ingredient.whole
{	
	import com.pblabs.engine.PBE;
	import com.pblabs.engine.entity.IEntity;
	import com.solidumgame.ninja.ingredient.types.IngredientType;
	
	import flash.geom.Point;
	
	/**
	 * 
	 * @author Tdadone
	 * 
	 */	
	
	public class WholeIngredient
	{
		protected var spatialComp:WholeIngredientSpatialComponent;
		protected var render:WholeIngredientRendererComponent;
		protected var logic:WholeIngredientLogicComponent;
		
		protected var myEntity:IEntity;
		
		
		public static const TYPE:String = "WholeIngredient";
		
		private static var numWholeIngredient:int = 0;
		
		private var type:IngredientType;
		/**
		 *	Constructor de la clase WholeIngredient. 
		 *  Se inicializan y agregan a la entidad los componentes spatial, renderer, logic. 
		 * 	Al agregar dichos componentes se les asigna un nombre a cada uno.
		 * 	Se inicializa la entidad y también se le asigna un nombre.
		 */		
		
		public function WholeIngredient(type:IngredientType)
		{
			this.type = type;
			
			spatialComp  = new WholeIngredientSpatialComponent(type);
			render = new WholeIngredientRendererComponent(type);
			logic = new WholeIngredientLogicComponent();
			
			myEntity = PBE.allocateEntity();
			myEntity.addComponent(spatialComp, "Spatial");
			myEntity.addComponent(render, "Renderer");
			myEntity.addComponent(logic, "Logic");
			myEntity.initialize("WholeIngredient"+numWholeIngredient++);		
		}
		
		/**
		 * Método para remover la entidad WholeIngredient. 
		 * Se destruye la entidad y se le asigna el valor null a todos sus componentes.
		 * 
		 */
		
		public function remove():void{
			myEntity.destroy();
			
			myEntity = null;
			spatialComp = null;
			logic = null;
			render = null;
		}

	}
}